package
{
	import flash.display.Sprite;
	import com.jidolstar.astro.*;	

	/**
	 * 날짜 변환 테스트
	 * @author Yongho, Ji
	 * @since 2009.05.12
	 */ 
	public class testDate extends Sprite
	{
		public function testDate()
		{
			super();
			trace( "================================ test Date ====================================");
			var date:ALDate; 
			date = new ALDate( 2009, 4, 8, 3, 18, 4, ALCalendarType.GREGORIAN ); //입력하는 년월일시분초는 Greogian 달력을 기준으로 하는 값임. 이 경우에는 null로 입력해도 동일   
			trace( date.toString() ); //2009-04-08 03:18:04.000
			trace( date.JD ); //2454929.637546296
			trace( date.JDN ); //2454929
			trace( date.dayOfWeek ); //3 : 수요일 
			trace( date.dayOfYear ); //98 : 2009년 1월 1일부터 2009년 4월 8일까지 98일임  
			trace( date.daysInYear ); //365 : 2009년은 365일임 
			trace( date.fractionalYear ); //2009.2661302638253 : 년도를 분수형태로 나타냄 
			trace( date.isLeapYear ); //false : 윤년이 아님 
			trace( date.MJD ); //54929.13754629623 : Modified Julian Date값
			trace( date.year, date.month, date.day, date.hour, date.minute, date.second ); //년,월,일,시,분,초 
			trace( date.datePartOfJD ); //2454929.5 일 
			trace( date.timePartOfJD ); //3.3011111095547676 h
			
			
			date = new ALDate( 2000, 1, 1, 0, 0, 0 );
			trace( date.toString() ); //2000-01-01 00:00:00.000
			trace( date.JD ); //2451544.5
			trace( date.JDN ); //2451544
			trace( date.dayOfWeek ); //6 : 토요일 
			trace( date.dayOfYear ); //1 : 2009년 1월 1일부터 2009년 1월 1일까지 1일임  
			trace( date.daysInYear ); //366 : 2009년은 365일임 
			trace( date.fractionalYear ); //2000 : 년도를 분수형태로 나타냄 
			trace( date.isLeapYear ); //true : 윤년임
			trace( date.MJD ); //51544 : Modified Julian Date값
			trace( date.year, date.month, date.day, date.hour, date.minute, date.second ); //년,월,일,시,분,초 
			trace( date.datePartOfJD ); //2451544.5일
			trace( date.timePartOfJD ); //0h

			date = new ALDate( 1988, 1, 27, null );
			trace( date.toString() ); //1988-01-27 00:00:00.000
			trace( date.JD ); //2447187.5

			date = new ALDate( 837, 4, 10.3 );
			trace( date.toString() ); //837-04-10 07:12:00.000
			trace( date.JD ); //2026871.8
			
			date = new ALDate( 2305812.5 );
			trace( date.toString() ); //1600-12-31 00:00:00.000
			trace( date.JD ); //2305812.5
			
			date = new ALDate( 0 );
			trace( date.toString() ); //-4712-01-01 12:00:00.000
			trace( date.JD ); //0
			
			date = new ALDate( 2400000.5 );
			trace( date.toString() ); //1858-11-17 00:00:00.000
			trace( date.JD ); //2400000.5
			
			trace( ALDate.date2JD( 837, 4, 10.3 ) ); //2026871.8	
			
			trace( ALDate.JD2MJD( 2451544.5 ) ); //51544
			
			trace( ALDate.isLeapYear( 2000 ) ); //true	
			
			//-----------------------------------------------------------------------
			// -584-05-28.63 UT, Astronomical Algorithms 2nd page.64 
			//-----------------------------------------------------------------------			
			date = new ALDate( -584, 5, 28.63 );
			trace( "----------------------------" );
			trace( date.toString(), date.fractionalDay ); //-584-05-28 15:07:12.00 28.62999999988824 		
			trace( date.JD ); //1507900.13
			date = ALDate.JD2Date( 1507900.13 );
			trace( date.JD ); //1507900.13
			trace( date.toString(), date.fractionalDay );//-584-05-28 15:07:12.00 28.62999999988824 	
			
			//-----------------------------------------------------------------------
			// 333-01-27.5 UT, Astronomical Algorithms 2nd page.64 
			//-----------------------------------------------------------------------			
			date = new ALDate( 333, 1, 27.5 );
			trace( "----------------------------" );
			trace( date.toString(), date.fractionalDay ); //333-01-27 12:00:00.00 27.5	
			trace( date.JD );  //1842713
			date = ALDate.JD2Date( 1842713.0 );
			trace( date.JD ); //1842713
			trace( date.toString(), date.fractionalDay ); //333-01-27 12:00:00.00 27.5					

			//-----------------------------------------------------------------------
			// 1957-10-04.81 UT, Astronomical Algorithms 2nd page.64 
			//-----------------------------------------------------------------------				
			date = new ALDate( 1957, 10, 4.81 );
			trace( "----------------------------" );
			trace( date.toString(), date.fractionalDay ); //1957-10-04 19:26:24.00 4.81000000005588
			trace( date.JD ); //2436116.31
			date = ALDate.JD2Date( 2436116.31 ); 
			trace( date.JD ); //2436116.31
			trace( date.toString(), date.fractionalDay ); //1957-10-04 19:26:24.00 4.81000000005588				

			//-----------------------------------------------------------------------
			// 1987-06-19 12:33:22 UT
			//-----------------------------------------------------------------------				
			date = new ALDate( 1987, 6, 19, 12, 33,22 );
			trace( "----------------------------" );
			trace( date.toString(), date.fractionalDay ); 	//1987-06-19 12:33:22.00 19.523171296343207	
			trace( date.JD ); //2446966.0231712963
			date = ALDate.JD2Date( 2446966.0231712963 );
			trace( date.JD ); //2446966.0231712963
			trace( date.toString(), date.fractionalDay ); //1987-06-19 12:33:22.00 19.523171296343207				
		}
		
	}
}